﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Data.SqlClient;

using Padelcenter.Common;

namespace Padelcenter.DataAccess
{
    #region " SELECT "
    #region " Media Select "
    public class Media_Select : DataAccessBase
    { 
        public Media_Select()
        {
            StoredProcedureName = StoredProcedure.Name.Media_SELECT.ToString();
        }

        public DataSet Get()
        {
            DataSet ds;

            Media_Select_Prm media_Select_Prm = new Media_Select_Prm(this.Media);
            DataBaseHelper dbhelper = new DataBaseHelper(StoredProcedureName);
            ds = dbhelper.Run(base.ConnectionString, media_Select_Prm.Parameters);

            return ds;
        }

        private Media _media;

        public Media Media
        {
            get { return _media; }
            set { _media = value; }
        }
    }

    public class Media_Select_Prm
    {
        public Media_Select_Prm(Media media)
        {
            this.Media = media;
            this.BuildParams();
        }

        private void BuildParams()
        {
            SqlParameter[] parameters = 
            {
                new SqlParameter( "@idMedia"            , this.Media.IdMedia),
                new SqlParameter( "@idTipoMedia"        , this.Media.TipoMedia.IdTipoMedia),
                new SqlParameter( "@ConFiltroActivo"    , this.Media.ConFiltroActivo),
                new SqlParameter( "@Activo"             , this.Media.Activo)
            };

            this.Parameters = parameters;
        }

        private Media _media;

        public Media Media
        {
            get { return _media; }
            set { _media = value; }
        }

        private SqlParameter[] _parameters;

        public SqlParameter[] Parameters
        {
            get { return _parameters; }
            set { _parameters = value; }
        }
    }

    #endregion

    #region " TipoMedia Select "

    public class TipoMedia_Select : DataAccessBase
    {
        public TipoMedia_Select() 
        {
            StoredProcedureName = StoredProcedure.Name.TipoMedia_SELECT.ToString();
        }

        public DataSet Get()
        {
            DataSet ds;

            TipoMedia_Select_Prm tipoMedia_Select_Prm = new TipoMedia_Select_Prm(this.TipoMedia);
            DataBaseHelper dbhelper = new DataBaseHelper(StoredProcedureName);
            ds = dbhelper.Run(base.ConnectionString, tipoMedia_Select_Prm.Parameters);

            return ds;
        }
        
        private TipoMedia _tipoMedia;

        public TipoMedia TipoMedia
        {
            get { return _tipoMedia; }
            set { _tipoMedia = value; }
        }
    }

    public class TipoMedia_Select_Prm
    {
        public TipoMedia_Select_Prm(TipoMedia tipoMedia)
        {
            this.TipoMedia = tipoMedia;
            this.BuildParams();
        }

        private void BuildParams()
        {
            SqlParameter[] parameters = 
            {
                new SqlParameter( "@idTipoMedia"        , this.TipoMedia.IdTipoMedia),
                new SqlParameter( "@ConFiltroActivo"    , this.TipoMedia.ConFiltroActivo),
                new SqlParameter( "@Activo"             , this.TipoMedia.Activo)
            };

            this.Parameters = parameters;
        }

        private TipoMedia _tipoMedia;

        public TipoMedia TipoMedia
        {
            get { return _tipoMedia; }
            set { _tipoMedia = value; }
        }

        private SqlParameter[] _parameters;

        public SqlParameter[] Parameters
        {
            get { return _parameters; }
            set { _parameters = value; }
        }
    }

    #endregion
    #endregion

    #region " INSERT "
    #region " Media Insert "
    public class Media_Insert : DataAccessBase
    {
        public Media_Insert()
        {
            StoredProcedureName = StoredProcedure.Name.Media_INSERT.ToString();
        }

        public DataSet Get()
        {
            DataSet ds;

            Media_Insert_Prm media_Insert_Prm = new Media_Insert_Prm(this.Media);
            DataBaseHelper dbhelper = new DataBaseHelper(StoredProcedureName);
            ds = dbhelper.Run(base.ConnectionString, media_Insert_Prm.Parameters);

            return ds;
        }

        private Media _media;

        public Media Media
        {
            get { return _media; }
            set { _media = value; }
        }
    }

    public class Media_Insert_Prm
    {
        public Media_Insert_Prm(Media media)
        {
            this.Media = media;
            this.BuildParams();
        }

        private void BuildParams()
        {
            SqlParameter[] parameters = 
            {
                new SqlParameter( "@idTipoMedia"        , this.Media.TipoMedia.IdTipoMedia),
                new SqlParameter( "@NombreArchivo"      , this.Media.NombreArchivo),
                new SqlParameter( "@Activo"             , this.Media.Activo)
            };

            this.Parameters = parameters;
        }

        private Media _media;

        public Media Media
        {
            get { return _media; }
            set { _media = value; }
        }

        private SqlParameter[] _parameters;

        public SqlParameter[] Parameters
        {
            get { return _parameters; }
            set { _parameters = value; }
        }
    }

    public class TipoMedia_Insert : DataAccessBase
    {
        public TipoMedia_Insert()
        {
            StoredProcedureName = StoredProcedure.Name.TipoMedia_INSERT.ToString();
        }

        public DataSet Get()
        {
            DataSet ds;

            TipoMedia_Insert_Prm tipoMedia_Insert_Prm = new TipoMedia_Insert_Prm(this.TipoMedia);
            DataBaseHelper dbhelper = new DataBaseHelper(StoredProcedureName);
            ds = dbhelper.Run(base.ConnectionString, tipoMedia_Insert_Prm.Parameters);

            return ds;
        }

        private TipoMedia _tipoMedia;

        public TipoMedia TipoMedia
        {
            get { return _tipoMedia; }
            set { _tipoMedia = value; }
        }
    }

    public class TipoMedia_Insert_Prm
    {
        public TipoMedia_Insert_Prm(TipoMedia tipoMedia)
        {
            this.TipoMedia = tipoMedia;
            this.BuildParams();
        }

        private void BuildParams()
        {
            SqlParameter[] parameters = 
            {
                new SqlParameter( "@Descripcion"        , this.TipoMedia.Descripcion),
                new SqlParameter( "@Activo"             , this.TipoMedia.Activo)
            };

            this.Parameters = parameters;
        }

        private TipoMedia _tipoMedia;

        public TipoMedia TipoMedia
        {
            get { return _tipoMedia; }
            set { _tipoMedia = value; }
        }

        private SqlParameter[] _parameters;

        public SqlParameter[] Parameters
        {
            get { return _parameters; }
            set { _parameters = value; }
        }
    }

    #endregion
    #endregion

    #region " UPDATE "

    public class Media_Update : DataAccessBase
    {
        public Media_Update()
        {
            StoredProcedureName = StoredProcedure.Name.Media_UPDATE.ToString();
        }

        public DataSet Get()
        {
            DataSet ds;

            Media_Update_Prm media_Update_Prm = new Media_Update_Prm(this.Media);
            DataBaseHelper dbhelper = new DataBaseHelper(StoredProcedureName);
            ds = dbhelper.Run(base.ConnectionString, media_Update_Prm.Parameters);

            return ds;
        }

        private Media _media;

        public Media Media
        {
            get { return _media; }
            set { _media = value; }
        }
    }

    public class Media_Update_Prm
    {
        public Media_Update_Prm(Media media)
        {
            this.Media = media;
            this.BuildParams();
        }

        private void BuildParams()
        {
            SqlParameter[] parameters = 
            {
                new SqlParameter( "@idMedia"            , this.Media.IdMedia),
                new SqlParameter( "@idTipoMedia"        , this.Media.TipoMedia.IdTipoMedia),
                new SqlParameter( "@NombreArchivo"      , this.Media.NombreArchivo),
                new SqlParameter( "@Activo"             , this.Media.Activo)
            };

            this.Parameters = parameters;
        }

        private Media _media;

        public Media Media
        {
            get { return _media; }
            set { _media = value; }
        }

        private SqlParameter[] _parameters;

        public SqlParameter[] Parameters
        {
            get { return _parameters; }
            set { _parameters = value; }
        }
    }

    public class TipoMedia_Update : DataAccessBase
    {
        public TipoMedia_Update()
        {
            StoredProcedureName = StoredProcedure.Name.TipoMedia_UPDATE.ToString();
        }

        public DataSet Get()
        {
            DataSet ds;

            TipoMedia_Update_Prm tipoMedia_Update_Prm = new TipoMedia_Update_Prm(this.TipoMedia);
            DataBaseHelper dbhelper = new DataBaseHelper(StoredProcedureName);
            ds = dbhelper.Run(base.ConnectionString, tipoMedia_Update_Prm.Parameters);

            return ds;
        }

        private TipoMedia _tipoMedia;

        public TipoMedia TipoMedia
        {
            get { return _tipoMedia; }
            set { _tipoMedia = value; }
        }
    }

    public class TipoMedia_Update_Prm
    {
        public TipoMedia_Update_Prm(TipoMedia tipoMedia)
        {
            this.TipoMedia = tipoMedia;
            this.BuildParams();
        }

        private void BuildParams()
        {
            SqlParameter[] parameters = 
            {
                new SqlParameter( "@idTipoMedia"        , this.TipoMedia.IdTipoMedia),
                new SqlParameter( "@Descripcion"        , this.TipoMedia.Descripcion),
                new SqlParameter( "@Activo"             , this.TipoMedia.Activo)
            };

            this.Parameters = parameters;
        }

        private TipoMedia _tipoMedia;

        public TipoMedia TipoMedia
        {
            get { return _tipoMedia; }
            set { _tipoMedia = value; }
        }

        private SqlParameter[] _parameters;

        public SqlParameter[] Parameters
        {
            get { return _parameters; }
            set { _parameters = value; }
        }
    }

    #endregion
}

